package mumu.android.app;

import java.util.Observable;
import java.util.Observer;

import mumu.android.R;
import mumu.android.lib.app.UnZipFile;
import mumu.android.lib.localstorage.FileSQLiteOpenHelper;
import mumu.android.lib.tool.Tools;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

/**
 * 
 * 观察者模式
 * 
 * @author Administrator
 * 
 */
public class observeractivity extends Activity implements Observer {

	TextView txt_1;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setTitle("observer");
		setContentView(R.layout.broadcast1);

		Button btn_1 = (Button) findViewById(R.id.btn_1);
		txt_1 = (TextView) findViewById(R.id.txt_1);
		btn_1.setText("观察者模式测试");
		btn_1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// 订阅通知
				UnZipFile.getInstance(observeractivity.this).addObserver(observeractivity.this);
				UnZipFile.getInstance(observeractivity.this).check();
			}
		});
	}

	@Override
	public void update(Observable observable, Object data) {
		if (observable instanceof UnZipFile)
			txt_1.setText(data.toString());
	}

}
